package com.xiaolee.hotool.json;

import java.util.List;

public class PathIterator {
    private int position;
    private int upBound;
    private List<PathSegment> segments;

    PathIterator(List<PathSegment> segments) {
        this.segments = segments;
        this.upBound = segments.size() -1;
        position = 0;
    }



    /**
     * 从索引0开始获取
     *
     * @return
     */
    public PathSegment get() {
        if (position > upBound) {
            // todo: error
        }

        return segments.get(position);
    }

    public PathIterator next() {
        position++;
        return this;
    }


    public boolean hasNext() {
        return position < upBound;
    }
}
